package io.cici.cc.mybatis.lite.executor.resultset;

import io.cici.cc.mybatis.lite.reflection.factory.ObjectFactory;

import java.util.ArrayList;
import java.util.List;

public class ResultContextHandlerImpl implements ResultContextHandler<Object> {

    private final List<Object> list;

    public ResultContextHandlerImpl() {
        list = new ArrayList<>();
    }

    @SuppressWarnings("unchecked")
    public ResultContextHandlerImpl(ObjectFactory objectFactory) {
        list = objectFactory.create(List.class);
    }

    @Override
    public void handle(ResultContext<?> resultContext) {
        list.add(resultContext.getObject());
    }

    public List<Object> getResultList() {
        return list;
    }

}
